from django.shortcuts import render

# Create your views here.
from rest_framework.generics import ListAPIView
from .models import UserCoupon
from .serializers import UserCouponModelSerializer
from rest_framework.permissions import IsAuthenticated
from django_filters.rest_framework import DjangoFilterBackend
# 判断优惠券的有效使用时间 : 开始启用时间 > 当前时间 - 有效期
class UserCouponListAPIView(ListAPIView):
    queryset = UserCoupon.objects.filter(is_show=True, is_delete=False, is_use=False ).order_by("-start_time")
    serializer_class = UserCouponModelSerializer
    permission_classes = [IsAuthenticated]
    filter_backends = [DjangoFilterBackend]
    filter_fields = ['user_id']